#!/bin/bash

OUT=src/shaders.h

echo "// Generated: $(date)" > ${OUT}
echo "#ifndef SHADERS_H" >> ${OUT}
echo "#define SHADERS_H" >> ${OUT}

for shader in $(ls data/*.glsl)
do
	name=$(echo $shader | sed -e "s/.*\///g" | sed -e "s/\..*//g")
	echo "" >> ${OUT}
	echo "// Contents of file ${name}" >> ${OUT}
	echo "static const char *${name} = \" \ " >> ${OUT}
	cat ${shader} | grep -v "^\s*//" | sed -e "s/\/\/.*//g" | grep -v "^$" | sed -e s/$/\\\\/g >> ${OUT}
	echo "\";" >> ${OUT}
	echo ${shader}
done

echo "#endif /* SHADERS_H */" >> ${OUT}	
